// 删除数据方法
export const delHandle = function({
  msg = '确定要删除这条数据吗?',
  title = '提示',
  submit = () => {},
  cancel = () => {}
}) {
  this.$confirm(msg, title)
    .then(async() => {
      submit()
    })
    .catch(() => {
      cancel()
    })
}

// 自动导入方法
export const importModulesFiles = function(modulesFiles, readDefault = false) {
  return modulesFiles.keys().reduce((modules, modulePath) => {
    const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
    if (moduleName.toLowerCase() === 'index') {
      return modules
    }
    let value = modulesFiles(modulePath)
    if (readDefault) {
      value = value.default
    }
    modules[moduleName] = value
    return modules
  }, {})
}

// 深拷贝方法
export const deepCopy = function(data) {
  return JSON.parse(JSON.stringify(data))
}
